package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.dao.impl.UserDaoImpl;
import com.itheima.domain.User;
import com.itheima.service.UserService;

import java.util.ArrayList;

public class UserServiceImpl implements UserService {
    @Override
    public ArrayList<User> findAll() {
        //让dao去查
        UserDao dao=new UserDaoImpl();
        return dao.findAll();
    }

    @Override
    public void add(User u) {
        //让dao去添加
        UserDao dao=new UserDaoImpl();
        dao.add(u);
    }

    @Override
    public void delete(String delId) {
        //让dao去删
        UserDao dao=new UserDaoImpl();
        dao.delete(delId);
    }

    @Override
    public User findById(String upid) {
        //让dao去查此id是否存在用户信息
        UserDao dao=new UserDaoImpl();
        return dao.findById(upid);
    }

    @Override
    public void update(User user) {
        //让dao去修改
        UserDao dao=new UserDaoImpl();
        dao.update(user);
    }

    @Override
    public User login(User u) {
        //让dao去登录账户信息
        UserDao dao=new UserDaoImpl();
        return dao.login(u);
    }
}
